package com.sun.hunk.hibernate.domain.impl;

import com.sun.hunk.hibernate.domain.GenericCode;
import com.sun.hunk.hibernate.domain.GenericCodeLabel;
import com.sun.hunk.hibernate.domain.GenericCodeValue;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author sunil
 */
@Entity
@Table(name = "generic_code_value")
public class GenericCodeValueImpl implements GenericCodeValue {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "value")
    private String value;
    @JoinColumn(name = "generic_code_label_id", referencedColumnName = "id")
    @ManyToOne(targetEntity=GenericCodeLabelImpl.class)
    private GenericCodeLabel genericCodeLabel;
    @JoinColumn(name = "generic_code_id", referencedColumnName = "id")
    @ManyToOne(targetEntity=GenericCodeImpl.class)
    private GenericCode genericCode;

    public GenericCodeValueImpl() {
    }

    public GenericCodeValueImpl(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public GenericCodeLabel getGenericCodeLabel() {
        return genericCodeLabel;
    }

    public void setGenericCodeLabel(GenericCodeLabel genericCodeLabel) {
        this.genericCodeLabel = genericCodeLabel;
    }

    public GenericCode getGenericCode() {
        return genericCode;
    }

    public void setGenericCode(GenericCode genericCode) {
        this.genericCode = genericCode;
    }
   
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GenericCodeValueImpl)) {
            return false;
        }
        GenericCodeValueImpl other = (GenericCodeValueImpl) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.cong.logiware.hibernate.domain.GenericCodeValue[id=" + id + "]";
    }

}
